home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 1.4 KB | 54 lines | [TEXT/MPS ] |
- ;
- ; File MacAppPatch.a
- ;
- ; Written by Mike Lockwood, September, 1990
- ;
- ;
- ; To build, execute these lines in MPW:
- ;
- ; asm MacAppPatch.a
- ; link MacAppPatch.a.o -o MacAppPatch -rt INIT=0 -t INIT -c '????'
-
-
- INCLUDE 'Traps.a'
-
- MAIN PROC EXPORT
- bra.s InstallPatch ; jump to patch installation
- PatchBegin
- move.l 4(sp),a0 ; Get ControlHandle
- move.l a0,-(sp) ; Put it on the stack for the real Draw1Control
- _HLock ; Lock ControlHandle
- move.l oldTrapAddr,a0 ; Get Addr of real Draw1Control
- jsr (a0) ; Execute it
- move.l 4(sp),a0 ; Get ControlHandle
- _HUnlock ; Unlock it
- move.l (sp)+,a0 ; Get return address
- addq #4,sp ; Clean up stack
- jmp (a0) ; return
- oldTrapAddr DC.L 0 ; address of real Draw1Control
- PatchEnd
-
- InstallPatch
- move #$16D,d0
- _GetTrapAddress newTool ; Get trap address for Draw1Control
- lea oldTrapAddr,a1 ; save it in oldTrapAddr
- move.l a0,(a1)
-
- move.l #(PatchEnd-PatchBegin),d4
- move.l d4,d0
- _NewPtr sys ; Allocate storage for patch in System heap
- move.l a0,a1
- move.l a1,a4
- lea PatchBegin,a0
- move.l d4,d0
- _BlockMove ; Copy patch to the System heap
-
- move #$16D,d0
- move.l a4,a0
- _SetTrapAddress newTool ; Set trap address for Draw1Control
-
- rts ; INIT done!
-
- ENDP
-
- END.